<template>
	<view class="hxaddress">
		<uni-nav-bar :fixed="true" status-bar :border="false" left-icon="left" title="核销奖品" @clickLeft="back" />
		<view class="box">
			<!-- <img class="x_fh"  src="../assets/6.png"  @click="x_fn"> -->
			<view class="shang">
				<view class="text">收货地址</view>
				<!-- <van-address-list v-model="chosenAddressId" :list="list" default-tag-text="默认" add-button-text="确认核销"
					@add="onAdd" @edit="onEdit" /> -->

				<!--收货地址-->
				<view class="list">
					<view class="name">收货人:</view>
					<view class="input_box">
						{{shouhuodz.name}}
					</view>

				</view>
				<view class="list">
					<view class="name">联系电话:</view>
					<view class="input_box">
						{{shouhuodz.phone}}
					</view>
				</view>

				<view class="list">
					<view class="name">所在地区:</view>
					<view class="input_box">
						{{shouhuodz.province}}{{shouhuodz.city}}{{shouhuodz.area}}
					</view>
				</view>
				<view class="list">
					<view class="name">详细地址:</view>
					<view class="input_box">
						{{shouhuodz.address}}
					</view>
				</view>
				<view class="list">
					<view class="name">邮政编码:</view>
					<view class="input_box">
						{{shouhuodz.post_code}}
					</view>
				</view>
				<view class="handle">
					<view class="btn" @click="onAdd">核销奖品</view>
					<view class="btn" @click="onEdit">修改地址</view>
				</view>

			</view>
			<view class="xia">
				<view class="top">奖品信息</view>
				<view class="di">
					<view class="img1" v-if="photo">
						<image :src="photo" style="width: 100%; height: 100%" />
					</view>
					<view class="item2">
						<view class="text1">
							{{ task_draw.level_name }}
							<view class="sl_x">x1</view>
						</view>
						<view class="text2">
							<view class="text2_1">{{ task_draw.draw_name }}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	// import {
	// 	myDraw,
	// 	drawInfo,
	// 	setAddress
	// } from "../api/lcreuse";
	export default {
		data() {
			return {
				chosenAddressId: "1",
				list: [{
					id: "1",
					isDefault: true,
				}, ],
				item: null,
				list_my: [],
				index: null,
				task_draw: [], //奖品等级---奖品名字
				photo: null,
				ym: "https://lottery.yywlcm.com/",
				// savedAddress:null,//保存收货信息
				shouhuodz: null,
			};
		},
		beforeCreate() {

		},
		onLoad(query) {
			if (query.shouhuodz) {
				this.shouhuodz = JSON.parse(query.shouhuodz);

				this.list[0].name = this.shouhuodz.name;
				this.list[0].tel = this.shouhuodz.phone;
				this.list[0].address = this.shouhuodz.address;
			}
			if (query.obj) {
				this.item = JSON.parse(query.obj);
				this.index = query.index;

				this.drawInfofn();
			}
		},
		mounted() {},
		methods: {
			back() {
				uni.navigateBack()
			},
			onAdd() {
				this.setAddressfn();
			},
			onEdit(item, index) {
				let id = JSON.parse(uni.getStorageSync('taskInfo', 'session')).task.id;
				let url = "/pagesPrize/aboutPrize/address?id=" + id + "&obj=" + JSON.stringify(this.item);
				uni.navigateTo({
					url
				})

			},
			// 我的奖品

			// 奖品详情
			async drawInfofn() {


				var res = await uni.$http.post('/wxuser/index/drawInfo', {
					draw_id: this.item.id
				})
				res = res.data;
				this.task_draw = res.data.task_draw;
				this.photo = `${uni.$http.baseUrl}/${this.task_draw.photo}`;
			},
			// 保存收货地址
			async setAddressfn() {

				var res = await uni.$http.post('/wxuser/draw/setAddress', this.shouhuodz);
				res = res.data;
				if (res.msg == "填写成功") {
					uni.showToast({
						title: "核销成功",
						icon: "success"
					})

					setTimeout(() => {
						// this.$router.back();
						let task = JSON.parse(uni.getStorageSync('taskInfo', 'session')).task;
						let url = `/pagesPrize/aboutPrize/information?id=${task.id}&index=1`;
						uni.navigateTo({
							url
						})

					}, 1500);
				}
			},
		},
	};
</script>
<style lang="scss">
	.hxaddress {
		height: 100vh;
		background-color: rgba(234, 242, 251, 0.37);
		padding: 0 20rpx;
		padding-top: 40rpx;

		.van-address-item {
			padding-left: 0;
		}

		.van-radio__icon {
			display: none;
		}

		.van-address-list__bottom {
			background: none !important;
		}

		.van-radio__label {
			margin-left: 0;
		}

		.van-button--round {
			background: #1e8cff !important;
			border: none !important;
		}

		.van-button {
			background: #1e8cff !important;
			/* 你想要的颜色 */
			border: none;
			padding-bottom: 0 !important;
		}

		.van-address-edit__buttons {
			padding-bottom: 0 !important;
		}

		.van-address-list {
			padding-bottom: 0 !important;
			padding-top: 0 !important;
			padding-left: 0;
		}

		.van-icon-success {
			background: #7ebcff !important;
			border-color: #7ebcff !important;
		}

		.van-tag--danger {
			background: #7ebcff !important;
		}

		.box {
			background: #ffffff;
			box-shadow: 0px 3rpx 22rpx 1rpx rgba(1, 60, 170, 0.16);
			// box-shadow: 0rpx 6rpx 20rpx 2rpx rgba(0, 0, 0, 0.16);
			padding: 34rpx;
			border-radius: 22rpx;
			padding-top: 40rpx;
			position: relative;
			margin-top: 30rpx;

			.handle {
				display: flex;
				margin-top: 20rpx;
				align-items: center;

				.btn {
					background: linear-gradient(142deg, #EFB565 0%, #D83626 100%);
					border-radius: 44rpx;
					color: #ffffff;
					font-size: 32rpx;
					padding: 11rpx 58rpx;
					margin: 0 20rpx;
				}
			}

			.x_fh {
				position: absolute;
				top: 20rpx;
				right: 20rpx;
				width: 40rpx;
				height: 40rpx;
			}

			.xia {
				padding-top: 30rpx;

				.di {
					display: flex;
					align-items: center;
					margin: 20rpx 0;

					.item2 {
						width: 75%;
						margin-left: 5%;

						.text1 {
							font-size: 32rpx;
							font-weight: 500;
							color: #D83724;
							margin-bottom: 10rpx;
							position: relative;

							.sl_x {
								position: absolute;
								right: 0;
								top: 0;
							}
						}

						.text2 {
							font-size: 28rpx;
							font-weight: 500;
							color: #888888;
							display: flex;

							.text2_2 {
								flex: 1;
								margin: 0 5%;
							}

							.text2_1 {
								flex: 1;
								font-size: 32rpx;
								color: #000;
							}

							.text2_3 {
								flex: 1;
							}
						}
					}

					.img1 {
						width: 120rpx;
						height: 120rpx;

						image {
							width: 120rpx;
							height: 120rpx;
						}

						// background-color: #7ebcff;
					}
				}

				.top {
					font-size: 32rpx;
					font-weight: 500;
					color: #000;
					padding: 15rpx 0;
				}
			}

			.shang {
				padding-bottom: 20rpx;
				border-bottom: 1px dashed #707070;


				.list {
					display: flex;
					margin-top: 10rpx;

					.name {
						color: #000;
						font-size: 28rpx;
						margin-right: 24rpx;
						height: 48rpx;
						line-height: 48rpx;
					}

					.input_box {
						flex: 1;

						.input {
							width: 100%;
							border-bottom: 1px solid #EEE;
							font-size: 28rpx;
							height: 48rpx;
							line-height: 48rpx;
						}
					}
				}

				.text {
					font-size: 32rpx;
					font-weight: 500;
					color: #000;
				}
			}
		}
	}
</style>